#include "stdafx.h"
#include "Box2DComponent.h"

namespace ZeEngine
{
    Box2DComponent::Box2DComponent(b2World* pWorld, b2Body* pBody) : m_pWorld(pWorld), m_pBody(pBody)
    {
        SetType(eBox2DComponent);

        if (m_pBody)
        {
            //For collision detection
            m_pBody->SetUserData(this);
        }
    }

    Box2DComponent::~Box2DComponent()
    {
        if (m_pBody)
        {
            m_pWorld->DestroyBody(m_pBody);
        }
    }

    void Box2DComponent::SetActive(bool fActive)
    {
		if (m_pBody && m_pBody->IsActive() != fActive)
        {
            m_pBody->SetActive(fActive);
        }
    }

    void Box2DComponent::Reset()
    {

    }
}
